import * as faceapi from "face-api.js";

main()

async function main(){
    // 加载模型权重文件
    await faceapi.nets.ssdMobilenetv1.loadFromUri('http://127.0.0.1:8888/weights')
    await faceapi.nets.faceLandmark68Net.loadFromUri('http://127.0.0.1:8888/weights')
    await faceapi.nets.faceRecognitionNet.loadFromUri('http://127.0.0.1:8888/weights')
    await faceapi.loadFaceLandmarkModel('http://127.0.0.1:8888/weights')

    let img = require('../public/images/sheldon/sheldon1.png')

    let currentImg = await faceapi.fetchImage(img)
    let landmarks = await faceapi.detectFaceLandmarks(currentImg)

    const canvas = faceapi.createCanvasFromMedia(currentImg)
    const box = document.getElementById('box')
    box.prepend(canvas)
    new faceapi.draw.DrawFaceLandmarks(landmarks, {drawLines:true}).draw(canvas)

    closeLoading()
}